<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonList.jsp" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>装修申办列表 (分帧页)</title>

<link href="${ctx}/css/grid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/scripts/global.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>

<script type="text/javascript">
	var requisitionId = "";
	var licenceState="";

	var ACTION_URL = "${ctx}/renovation_renovateRequisitionAction.do?";

	function setClickInfo(keyword,licenceState){//单击数据行时，设置申请Id
		parent.requisitionId=keyword;
		this.requisitionId = keyword;
		this.licenceState =licenceState;
	}

	function checkSubmit(){//检查是否可以进行提交操作
		var url = ACTION_URL+"method=checkSubmitPage";

		new Ajax.Request(url,
			         { method:'post',
					   parameters:{requisitionId:requisitionId},
					   onComplete:openSubmitPage
					 });
	}
	function openSubmitPage(response){//打开提交页面
		var flag = response.responseText;
		if (flag == "false"){
			Alert("只有新建状态的数据才能进行提交！");
			return ;
		}

		//var url = ACTION_URL+"method=navigateSubmitPage&requisitionId="+requisitionId;//打开提交页面
   		//top.windowOpen(url, "submitPage", "提交", 400, 500,true,"submitPageIfm");

   		AskConfirm("确定要提交这条记录吗?","proceduresRenovationFrm","editSubmit");
	}

	function editSubmit(flag,reqId){	//提交操作
		var requisId = "";
		if(flag == "addToSubmit"){
			requisId=reqId;
		}else{
			requisId=requisitionId;
		}

		var params ="";
		var url =ACTION_URL+"method=sumbitInfo&requisitionId="+requisId;

		new Ajax.Request(url,
			         { method:'post',
					   asynchronous:false,
					   onComplete:submitReturn
					 });
	}

	function submitReturn(response){
		ajaxSubmitException(response.responseText);
		findFrame('main').refleshRenReqFrame();  //刷新主页面列表
	}

	function openSubmit(requisitionId){//新增，修改页面请求提交

		var url = ACTION_URL+"method=navigateSubmitPage&requisitionId="+requisitionId;
   		top.windowOpen(url, "submit", "提交", 400, 500,true,"submitIfm");
	}

	function checkReqCharge(){//检查是否可以进行收费登记
		var url = ACTION_URL+"method=checkReqCharge";
		new Ajax.Request(url,
			         { method:'post',
					   parameters:{requisitionId:requisitionId,licenceState:licenceState},
					   onComplete:openReqCharge
					 });
	}
	function openReqCharge(response){//打开收费登记页面

		var flag = response.responseText;
		if (flag == "licence"){
			Alert("已发放许可证不能进行登记收费！");
			return ;
		}else if(flag == "abnormityNopass") {
			Alert("已异常完结(审批不通过)不能进行登记收费！");
			return ;
		}else if (flag == "abnormityNull"){
			Alert("已异常完结(--)不能进行登记收费！");
			return ;
		}

		var url = ACTION_URL+"method=navigateRequisitionCharge&keyword="+requisitionId;
   		top.windowOpen(url, "reqCharge", "收费登记", 380, 850,true,"reqChargeIfm");
	}

	function checkConfirm(){ //检查是否可以进行进场确认
	var url = ACTION_URL+"method=checkConfirm";
		new Ajax.Request(url,
			         { method:'post',
					   parameters:{requisitionId:requisitionId},
					   onComplete:openCheckConfirm
					 });
	}

	function openCheckConfirm(response){//打开进场确认
		var flag = response.responseText;
		if (flag == "noPass"){
			Alert("审批通过后才能进行进场确认！");
			return ;
		}else if(flag == "finish") {
			Alert("已完结，不能进行进场确认！");
			return ;
		}

		var url = ACTION_URL+"method=navigateCheckConfirm&keyword="+requisitionId;
   		top.windowOpen(url, "checkConfig", "进场确认", 390, 850,true,"checkConfirmIfm");
	}

	function checkLicence(){//检查是否可以打开许可证页面
		var url = ACTION_URL+"method=checkTransactLicence";
		new Ajax.Request(url,
			         { method:'post',
					   parameters:{keyword:requisitionId},
					   onComplete:openLicence
					 });
	}
	function openLicence(response){//打开许可证页面
		var flag = response.responseText;

		if (flag == "finish"){
			Alert("已完结，不能发放许可证！");
			return ;
		}else if(flag == "noPass") {
			Alert("还未审核通过，不能发放许可证！");
			return ;
		}else if(flag == "noFee"){
			Alert("未缴费，不能发放许可证！");
			return ;
		}else if(flag == "reinspectionPass"){
			Alert("复验通过，不能修改许可证！");
			return ;
		}


		var url = ACTION_URL+"method=navigateTransactLicence&keyword="+requisitionId;
   		top.windowOpen(url, "licence", "许可证发证", 400, 850,true,"licenceIfm");
	}

	function openDetailPage(requisitionId){ //双击打开详细页面
		this.requisitionId = requisitionId;
		var url = ACTION_URL+"method=navigateProceduresDetailMain&requisitionId="+requisitionId;
   		top.windowOpen(url, "proceduresDetailMain", "详细资料", 560, 810,true,"proceduresDetailMainIfm");
	}

	function checkApproval(){//检查是否可以进行审批
		var url = ACTION_URL+"method=checkRenovateApproval";
		new Ajax.Request(url,
			         { method:'post',
					   parameters:{keyword:requisitionId},
					   onComplete:openApprovalPage
					 });
	}

	function openApprovalPage(response){ //打开审批页面
		var msg = response.responseText;
		if (msg != "true"){
			Alert(msg);
			return ;
		}
		var url = ACTION_URL+"method=navigateRenovateApproval&keyword="+requisitionId;
   		top.windowOpen(url, "renovateApproval", "装修申办审批", 720, 850,true,"renovateApprovalIfm");
	}

	function resize(){
		parent.window.document.all('proceduresRenovationFrm').style.height=document.body.scrollHeight;
	}

	function init(){  //初始化
		parent.requisitionId=""
		parent.cur_p='${ec_p}';
		resize();
	}
</script>

</head>
<body onload="init();">

<div style="overflow:auto;" id="divId" >
	<ec:ceTable items="reqlist"
				autoIncludeParameters="true"
				var="reqItem"
				action="${ctx}/renovation_renovateRequisitionAction.do?method=queryRequisitions"
				rowsDisplayed="15"
				width="100%"
				view="pmsview"
				sortable="false"
				styleClass="gridData"
			>
		<ec:ceRow styleClass="grid" ondblclick="openDetailPage('${reqItem.keyword}');" onclick="setClickInfo('${reqItem.keyword}','${reqItem.renovateLicenceState}');"  onContextMenu="return ShowContextMenu(event,'quick_rightmenu');">
			<ec:ceColumn width="12%" property="requisitionNumber" headerCell="pmsHeadrCell"  title="申请单号" sortable="true"/>
			<ec:ceColumn width="6%"  property="houseNumber" headerCell="pmsHeadrCell"  title="房 号" sortable="true"></ec:ceColumn>
			<ec:ceColumn width="8%"  property="clientNames" headerCell="pmsHeadrCell"  title="业主姓名"/>
			<ec:ceColumn width="10%"  property="requisitionDate" headerCell="pmsHeadrCell" title="装修申请日期" sortable="true"  cell="date" parse="yyyy-MM-dd" />
			<ec:ceColumn width="17%"  property="#" headerCell="pmsHeadrCell" title="装修施工期限">
				<fmt:formatDate pattern="yyyy-MM-dd" value="${reqItem.beginDate }"/>到<fmt:formatDate pattern="yyyy-MM-dd" value="${reqItem.endDate }"/>
			</ec:ceColumn>
			<ec:ceColumn width="8%"  property="requisitionStateView" headerCell="pmsHeadrCell" title="审批状态">${reqItem.requisitionStateView == null ? '&nbsp;— —' : reqItem.requisitionStateView } </ec:ceColumn>
			<ec:ceColumn width="8%"  property="feeStateView" headerCell="pmsHeadrCell"  title="费用状态"></ec:ceColumn>
			<ec:ceColumn width="8%"  property="renovateLicenceStateView" headerCell="pmsHeadrCell" title="发证状态" />
			<ec:ceColumn width="8%"  property="checkConfirmYnView" headerCell="pmsHeadrCell" title="进场确认" />
			<ec:ceColumn width="13%"  property="processState" headerCell="pmsHeadrCell" title="装修进程" showTitle="false">
				<c:choose>
					<c:when test="${reqItem.processState =='001'}">
						<img src="${ctx}/images/ico_zx_shen11.gif" alt="装修申办" width="16" height="16" border="0" align="middle"/>&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_jian3.gif" alt="装修监管" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_yan2.gif" alt="竣工验收" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_tui3.gif" alt="保证金核算" width="16" height="16" border="0" align="middle" />
					</c:when>
					<c:when test="${reqItem.processState == '002'}">
						<img src="${ctx}/images/ico_zx_shen11.gif" alt="装修申办" width="16" height="16" border="0" align="middle"/>&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_jian1.gif" alt="装修监管" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_yan2.gif" alt="竣工验收" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_tui3.gif" alt="保证金核算" width="16" height="16" border="0" align="middle" />
					</c:when>
					<c:when test="${reqItem.processState == '003'}">
						<img src="${ctx}/images/ico_zx_shen11.gif" alt="装修申办" width="16" height="16" border="0" align="middle"/>&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_jian1.gif" alt="装修监管" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_yan1.gif" alt="竣工验收" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_tui3.gif" alt="保证金核算" width="16" height="16" border="0" align="middle" />
					</c:when>
					<c:otherwise>
						<img src="${ctx}/images/ico_zx_shen11.gif" alt="装修申办" width="16" height="16" border="0" align="middle"/>&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_jian1.gif" alt="装修监管" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_yan1.gif" alt="竣工验收" width="16" height="16" border="0" align="middle" />&nbsp;&nbsp;&nbsp;
						<img src="${ctx}/images/ico_zx_tui1.gif" alt="保证金核算" width="16" height="16" border="0" align="middle" />
					</c:otherwise>
				</c:choose>
			</ec:ceColumn>
		</ec:ceRow>
	</ec:ceTable>
</div>
<!--------------装修申请 右键开始------------------------>
<div id="quick_rightmenu" style="display:none;" oncontextmenu="return false" class="quick_menu2" onMouseOver="showmy2menu('quick_rightmenu')"  onMouseOut="hidden2menu('quick_rightmenu')" >
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="grid_quickMenu_bg">
    <tr>
      <td><table width="100%" border="0" cellpadding="2" cellspacing="0">
        <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=addRequisition">
        <tr>
        	<td class="quickMenu_toolbarico"><a href="#"  onClick="parent.openRequisitionAdd();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" alt="新建" width="16" height="16" border="0" align="absbottom" /> 新 建</a></td>
        </tr>
        </pms:AuthTag>
         <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=editRequisition">
        <tr>
        	<td class="quickMenu_toolbarico"><a href="#"  onClick="parent.checkEdit();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改" /> 修 改</a></td>
        </tr>
        </pms:AuthTag>
         <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=deleteRequisition">
        <tr>
        	<td class="quickMenu_toolbarico"><a href="#" onClick="parent.checkDelete();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom" /> 删 除</a></td>
        </tr>
        <tr>
        	<td class="hrpading">
	        	<table width="95%" border="0" align="left" cellpadding="0" cellspacing="0"><tr><td class="quickMenu_line"></td></tr></table>
        	</td>
        </tr>
        </pms:AuthTag>
         <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=sumbitInfo">
        <tr>
          <td class="quickMenu_toolbarico"><a href="#" onClick="checkSubmit();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_submit.gif" alt="提 交" width="16" height="16" border="0" align="absbottom" /> 提 交</a></td>
        </tr>
		<tr>
          <td class="hrpading">
	          <table width="95%" border="0" align="left" cellpadding="0" cellspacing="0">
	            <tr><td class="quickMenu_line"></td></tr>
	          </table>
          </td>
        </tr>
        </pms:AuthTag>
 <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=navigateRenovateApproval">
        <tr>
          <td class="quickMenu_toolbarico"><a href="#"  onClick="checkApproval();return false;" onFocus="this.blur()"><img src="${ctx }/images/ico_shenpi_zong1.gif" border="0" align="absbottom" />&nbsp;审 批</a></td>
        </tr>
</pms:AuthTag>
 <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=navigateRequisitionCharge">
		<tr>
          <td class="quickMenu_toolbarico"><a href="#"  onclick="checkReqCharge();return false;" onfocus="this.blur()"><img src="${ctx}/images/ico_zxsoufei.gif" alt="收费登记" border="0" align="absbottom" />&nbsp;收费登记</a></td>
        </tr>
        </pms:AuthTag>
         <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=navigateCheckConfirm">
		<tr>
          <td class="quickMenu_toolbarico"><a href="#" onClick="checkConfirm();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_charge_bgfa.gif" alt="进场确认" border="0" align="absbottom" />&nbsp;进场确认</a></td>
        </tr>
        </pms:AuthTag>
         <pms:AuthTag authName="renovation_renovateRequisitionAction.do?method=editTransactLicence">
		<tr>
          <td class="quickMenu_toolbarico"><a href="#"  onclick="checkLicence();return false;" onfocus="this.blur()"><img src="${ctx}/images/ico_xukezhen.gif" alt=" 许可证" width="16" height="16" border="0" align="absbottom" /> 许可证</a></td>
        </tr>
        </pms:AuthTag>
      </table></td>
    </tr>
  </table>
<script type="text/javascript">

	var div1=document.getElementById('quick_rightmenu');
	if(div1.getElementsByTagName("tr").length==1){
	div1.innerHTML="";
	}
</script>
</div>
</body>
</html>
